import {updateIntl} from '../reducers/intl';
import AsyncStorage from '@react-native-async-storage/async-storage';

export function change(payload) {
  return dispatch => {
    AsyncStorage.setItem('@language', payload);
    dispatch(updateIntl(payload));
  };
}

export function load() {
  return async dispatch => {
    const language = await AsyncStorage.getItem('@language');
    if (language) {
      dispatch(updateIntl(language));
    }
  };
}
